import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  // 加载对应环境变量
  const env = loadEnv(mode, process.cwd())
  return {
    base: './', // 关键！让资源用相对路径
    plugins: [vue()],
    server: {
      port: 5173 //端口
    },
    define: {
      'process.env': env
    },
    build: {
      outDir: 'dist/web',
      emptyOutDir: true
    } ,
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
        "@cp": path.resolve(__dirname, 'src/components'),
        "@as": path.resolve(__dirname, 'src/assets'),
        "@st": path.resolve(__dirname, 'src/store'),
        "@ut": path.resolve(__dirname, 'src/utils')


      }
    },
  }
})
